package com.antler.smt.admin.service.impl;

import com.antler.smt.admin.mapper.JobOrderCommentEntityMapper;
import com.antler.smt.admin.mapper.PeopleInfoEntityMapper;
import com.antler.smt.admin.mapper.RecruitmentInfoEntityMapper;
import com.antler.smt.entity.JobOrderCommentEntity;
import com.antler.smt.entity.PeopleInfoEntity;
import com.antler.smt.entity.RecruitmentInfoEntity;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.admin.AuditService;
import com.antler.smt.utils.DateUtil;
import com.antler.smt.utils.ReturnResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zhangyi
 * @date 2018/7/17 11:33
 */
@Service
public class AuditServiceImpl implements AuditService {

    @Autowired
    private JobOrderCommentEntityMapper jobOrderCommentEntityMapper;

    @Autowired
    private RecruitmentInfoEntityMapper recruitmentInfoEntityMapper;

    @Autowired
    private PeopleInfoEntityMapper peopleInfoEntityMapper;
    /**
     * 审核人员信息
     *
     * @param id
     * @param auditStatus
     * @return
     */
    @Override
    public Result auditPeopleInfo(Long id, Integer auditStatus) {
        //创建人员信息实体
        PeopleInfoEntity peopleInfoEntity = new PeopleInfoEntity();
        peopleInfoEntity.setId(id);
        peopleInfoEntity.setStatus(auditStatus);
        peopleInfoEntity.setUpdateDate(DateUtil.stampToDate(System.currentTimeMillis()));
        int i = peopleInfoEntityMapper.updateByPrimaryKeySelective(peopleInfoEntity);
        return ReturnResultUtil.getResult("人员信息审核成功！"
                ,"人员信息审核失败！",i);
    }

    /**
     * 审核发布需求信息
     *
     * @param id
     * @param auditStatus
     * @return
     */
    @Override
    public Result auditRecruitmentInfo(Long id, Integer auditStatus) {
        RecruitmentInfoEntity recruitmentInfoEntity = new RecruitmentInfoEntity();
        recruitmentInfoEntity.setId(id);
        recruitmentInfoEntity.setAuditStatus(auditStatus);
        recruitmentInfoEntity.setUpdateTime(DateUtil.stampToDate(System.currentTimeMillis()));
        int i = recruitmentInfoEntityMapper.updateByPrimaryKeySelective(recruitmentInfoEntity);
        return ReturnResultUtil.getResult("发布招聘需求信息审核成功！"
                ,"发布招聘需求信息审核失败！",i);
    }

    /**
     * 审核工作评价信息
     *
     * @param id
     * @param auditStatus
     * @return
     */
    @Override
    public Result autditJobComment(Long id, Integer auditStatus) {
        JobOrderCommentEntity jobOrderCommentEntity = new JobOrderCommentEntity();
        jobOrderCommentEntity.setId(id);
        jobOrderCommentEntity.setAuditStatus(auditStatus);
        jobOrderCommentEntity.setUpdateTime(DateUtil.stampToDate(System.currentTimeMillis()));
        int i = jobOrderCommentEntityMapper.updateByPrimaryKeySelective(jobOrderCommentEntity);
        return ReturnResultUtil.getResult("工作评价信息审核成功！"
                ,"工作评价信息审核失败！",i);
    }
}
